/**
 * Created by Administrator on 2016/6/21.
 */
import React from 'react';
import styles from '../../style.css';

class LikeButton extends React.Component{
  constructor(props) {
    super(props);
    this.state = {text: '我会跟着上面动'};
  }
  handleChange(e){
    var text = this.refs.input.value;
    if(text == ''){
      this.setState({text: '我会跟着上面动'})
    }else{
      this.setState({text:text});
    }
    
  }
  render() {
    let text = this.state.text;

    return (
      <div>
        <input type="text" onChange={this.handleChange.bind(this)} ref="input"/>
        <p>{text}</p>
      </div>
    );
  }
}

export default class Example6 extends React.Component{
  render() {
    return (
      <div className={styles.app}>
        <LikeButton />
      </div>
    )
  }
}